<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>${constants.getSystemName()}</title>
    <link rel="stylesheet" href="${ctxPath}/assets/common/libs/layui/css/layui.css?v=${constants.getReleaseVersion()}"/>
    <link rel="stylesheet" href="${ctxPath}/assets/common/module/admin.css?v=${constants.getReleaseVersion()}"/>
    <link rel="stylesheet" href="${ctxPath}/assets/expand/css/style.css?v=${constants.getReleaseVersion()}" media="all"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15" >
        <div class="layui-col-lg12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div id="Process Open Files" style="width: 100%;min-height:300px"></div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row layui-col-space15" >
        <div class="layui-col-lg6">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div id="CPU Usage" style="width: 100%;min-height:300px"></div>
                </div>
            </div>
        </div>
        <div class="layui-col-lg6">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div id="Load Average" style="width: 100%;min-height:300px"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- js部分 -->
@/* 加入contextPath属性和session超时的配置 */
<script type="text/javascript">
    var Feng = {
        ctxPath: "${ctxPath}",
        version: '${constants.getReleaseVersion()}'
    };
</script>
<script type="text/javascript" src="${ctxPath}/assets/common/libs/layui/layui.js?v=${constants.getReleaseVersion()}"></script>
<script type="text/javascript" src="${ctxPath}/assets/common/js/common.js?v=${constants.getReleaseVersion()}"></script>
<script src="${ctxPath}/assets/common/libs/echarts/echarts.min.js?v=${constants.getReleaseVersion()}"></script>
<script src="${ctxPath}/assets/common/libs/echarts/echartsTheme.js?v=${constants.getReleaseVersion()}"></script>
<script src="${ctxPath}/assets/common/js/echartInit.js?v=${constants.getReleaseVersion()}"></script>
<script>
    layui.use(['layer','HttpRequest'], function () {
        const $ = layui.jquery;
        let HttpRequest = layui.HttpRequest;
        const cpuUrl = "/view/monitor/getCpuInfo";
        let cpuRequest = new HttpRequest(cpuUrl, 'get',function (cpuData) {
            let cpuParams = {
                id: 'CPU Usage',
                title: 'CPU Usage',
                metric : {
                    metric1: {
                        name: 'System CPU Usage',
                        value: cpuData.system_cpu_usage
                    },
                    metric2: {
                        name: 'Process CPU Usage',
                        value: cpuData.process_cpu_usage
                    },
                    metric3: {
                        name: '',
                        value: []
                    }
                }
            }
            initMultiGraph(cpuParams);
        })
        cpuRequest.setAsync(true);
        cpuRequest.start();

        const loadUrl = "/view/monitor/getLoadInfo";
        let loadRequest = new HttpRequest(loadUrl, 'get',function (loadData) {
            let loadParams = {
                id: 'Load Average',
                title: 'Load Average',
                metric : {
                    metric1: {
                        name: 'Load Average [1m]',
                        value: loadData.system_load_average_1m
                    },
                    metric2: {
                        name: 'CPU Core Size',
                        value: loadData.system_cpu_count
                    },
                    metric3: {
                        name: '',
                        value: []
                    }
                }
            }
            initMultiGraph(loadParams);
        })
        loadRequest.setAsync(true);
        loadRequest.start();

        const processUrl = "/view/monitor/getProcessInfo";
        let processRequest = new HttpRequest(processUrl, 'get',function (processData) {
            let processParams = {
                id: 'Process Open Files',
                title: 'Process Open Files',
                metric : {
                    metric1: {
                        name: 'Open Files',
                        value: processData.process_files_open_files
                    },
                    metric2: {
                        name: 'Max Files',
                        value: processData.process_files_max_files
                    },
                    metric3: {
                        name: '',
                        value: []
                    }
                }
            }
            initMultiGraph(processParams);
        })
        processRequest.setAsync(true);
        processRequest.start();
    });
</script>
</body>
</html>